import React from 'react';

// eslint-disable-next-line import/no-anonymous-default-export
export default Componet => {
  return class WrapperComponet extends React.Component {
    // eslint-disable-next-line no-useless-constructor
    constructor(props) {
      super(props);
      this.state = {
        positionx: 0,
        positiony: 0,
      };
    }
    componentDidMount() {
      const that = this;
      document.addEventListener('mousemove', e => {
        that.setState({
          positionx: e.clientX,
          positiony: e.clientY,
        });
      });
    }
    componentWillUnmount() {
      document.removeEventListener('mousemove', e => {
        console.log(e);
      });
    }
    render() {
      return <Componet {...this.props} {...this.state} />;
    }
  };
};
